<?php

function getGoodsByProprio($BDD_connexion,$id)
{
	
	$goods = array();
	
	$request = "SELECT * FROM bien WHERE ref_proprio = :id";
	$prepare = $BDD_connexion->prepare($request);
	$prepare->bindValue(':id',$id,PDO::PARAM_INT);
	$prepare->execute();
	
	while ($good = $prepare->fetch(PDO::FETCH_OBJ))
	{
		
		$goods[] = $good;
		
	}
	
	return $goods;
	
}

function isGoodLocation($locations,$id_location)
{
	
	foreach ($locations as $location)
	{
		
		if ($location->id_location == $id_location && $location->etat == "0")
		{
			return true;
		}
		
	}
	
	return false;
	
}

function getLocationPersonsByGood($BDD_connexion,$id_bien)
{
	
	$people = array();
	
	$request = "SELECT * FROM personne WHERE id IN (SELECT ref_personne FROM bien WHERE id_bien = :id_bien AND ref_personne != ref_proprio)";
	$prepare = $BDD_connexion->prepare($request);
	$prepare->bindValue(':id_bien',$id_bien,PDO::PARAM_INT);
	$prepare->execute();
	
	while ($person = $prepare->fetch(PDO::FETCH_OBJ))
	{
		
		$people[] = $person;
		
	}
	
	return $people;
	
}

?>
